<?php
/**
 * Created by PhpStorm.
 * User: 764432054@qq.com
 * Date: 2019/2/27
 * Time: 2:03
 */
echo "start".PHP_EOL;
$t1=time();
$workers=[];
$urls=[
    'http://a.com',
    'http://b.com',
    'http://c.com',
    'http://d.com',
    'http://e.com',
];
$len=count($urls);
for($i=0;$i<$len;$i++){
    $process=new swoole_process(function(swoole_process $worker)use($i,$urls){
        $content=curlData($urls[$i]);
        echo ($content.PHP_EOL);
//        $worker->write($content.PHP_EOL);
    },true);

    $pid=$process->start();
    $workers[$pid]=$process;

}
foreach($workers as $process){
   echo  $process->read();
}

function curlData($url){
    sleep(1);

    return $url.PHP_EOL;
}
$t2=time();
echo "end:".($t2-$t1).PHP_EOL;






















